/*
 * Copyright 2009 Eat Local Food, LLC
 * Copyright (c) 2007 osCommerce (this file was written after
 * code review of osCommerce).
 *
 * This file is part of gwtCommerce.
 *
 * gwtCommerce is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * gwtCommerce is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with gwtCommerce.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.elf.gwt.admin.client.components;

import com.elf.gwt.admin.client.AdminComponentController;
import com.elf.gwt.common.client.model.GroupModel;

/**
 *
 */
public class GroupMemberComponent extends AdminSimpleComponent
{	
	protected String groupComponentHandle = null;
	protected GroupModel selectedGroup = null;
	
	/**
	 * Constructor
	 */
	public GroupMemberComponent(AdminComponentController controller, String stylePrefix)
	{
		super(controller, stylePrefix);
	}

	public void build()
	{
	}

	public boolean updateFromHistoryParameters(String[] params)
	{
		if (params.length > 1)
		{
			int id = Integer.parseInt(params[1]);
			GroupComponent groupComponent = (GroupComponent)controller.getComponent(groupComponentHandle);
			groupComponent.setSelectedGroupModel(id);	
			groupComponent.setSelectedInGUI();	
			adminController.getNavigationStackPanel().showStack(groupComponent.getIndex());	
			GroupModel groupModel = groupComponent.getSelectedGroupModel();
			setSelectedGroup(groupModel);
		}
		return super.updateFromHistoryParameters(params);
	}

	public AdminSimpleComponent getComponent(String handle) {
		return null;
	}
	
	public GroupModel getSelectedGroup() {
		return selectedGroup;
	}

	public void setSelectedGroup(GroupModel selectedGroup) {
		this.selectedGroup = selectedGroup;
	}

	public String getGroupComponentHandle() {
		return groupComponentHandle;
	}

	public void setGroupComponentHandle(String groupComponentHandle) {
		this.groupComponentHandle = groupComponentHandle;
	}

}
